//
//  DBKit.h
//  nonghubao
//
//  Created by 王 文彬 on 13-1-23.
//  Copyright (c) 2013年 mypocketbaby. All rights reserved.
//

#import <Foundation/Foundation.h>

@class FMDatabase;
@class FMResultSet;
@class ManagedDBObject;
@class Option;
@class Contact;

@interface DBKit : NSObject
{
    FMDatabase* _connection;                   //数据库连接句柄
}

//单例方法
+ (DBKit *)sharedDBKit;

//定义数据库的版本信息
typedef NS_ENUM(NSInteger, DBVersion) {
    DBVersionV1,
    DBVersionV2 = 176
};
//根据数据库版本，初始化数据库
- (void)initDB:(DBVersion)version;

//根据一个name，返回一个Option
- (Option *)optionWithName:(NSString *)name;

- (NSMutableArray *)transformToContactInfo;
- (NSMutableArray *)getAnnouncementsFromDB;
//- (void)updateStatus:(NSInteger)status WithAnnouncementId:(NSInteger)announcementId;
//- (void)deleteAnnouncement;

- (BOOL)save:(ManagedDBObject *)object;
- (BOOL)remove:(ManagedDBObject *)object;

- (BOOL)executeSQL:(NSString *)sql;
- (FMResultSet *)querySQL:(NSString *)sql;

- (void)truncateCollageTable;
@end
